#include "VertexArray.h"
#include "VertexLayout.hpp"
VertexArray::VertexArray(const VertexBuffer &vb, const VertexLayout &layout, const IndexBuffer &ib)
{
	glGenVertexArrays(1, &m_id);
	glBindVertexArray(m_id);
	layout.bindToVertexArray(*this);
	vb.bind();
	ib.bind();
}

void VertexArray::bind() const
{
	glBindVertexArray(m_id);
}

void VertexArray::unbind() const
{
	glBindVertexArray(0);
}

VertexArray::~VertexArray()
{
	glDeleteVertexArrays(1, &m_id);
}
